home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20010921-20020314 / 000355_kroneru@yahoo.com_Tue Feb 5 13:30:08 EST 2002.msg < prev    next >
Text File  |  2020-01-01  |  14KB  |  405 lines

  1. Article: 13196 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!panix!bloom-beacon.mit.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
  3. From: kroneru@yahoo.com (Ulrich Kroener)
  4. Newsgroups: comp.unix.solaris,comp.protocols.kermit.misc,comp.lang.java.programmer
  5. Subject: getRuntime().exec() of command line kermit ftp script causes SIGSEGV, shell launch does not
  6. Date: 5 Feb 2002 10:17:05 -0800
  7. Organization: http://groups.google.com/
  8. Lines: 387
  9. Message-ID: <84e28e35.0202051017.ddd6262@posting.google.com>
  10. NNTP-Posting-Host: 212.35.110.98
  11. Content-Type: text/plain; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Trace: posting.google.com 1012933025 3781 127.0.0.1 (5 Feb 2002 18:17:05 GMT)
  14. X-Complaints-To: groups-abuse@google.com
  15. NNTP-Posting-Date: 5 Feb 2002 18:17:05 GMT
  16. Xref: newsmaster.cc.columbia.edu comp.unix.solaris:373835 comp.protocols.kermit.misc:13196 comp.lang.java.programmer:499449
  17.  
  18. Hello!
  19.  
  20. We have a problem with a Solaris installation, with Java (any version)
  21. launching a Kermit FTP job.
  22.  
  23. Configurations: 
  24.  - Solaris SunOS XXXXX 5.8 Generic_108528-10 sun4u sparc
  25. SUNW,UltraAX-i2
  26.  - both java 1.1.8_12 and java 1.3.0_02 cause problems
  27.  - Kermit versions "C-Kermit 8.0.200 Beta.03, 9 Sep 2001, for Solaris
  28. 8" and "C-Kermit 8.0.200, 12 Dec 2001, for Solaris 8", compiled using
  29. cc, cause problems
  30.  
  31. We are trying to use C-Kermit to transfer a file using the "FTP
  32. personality" to a different machine. The script works from the command
  33. line, but when invoked by Runtime.getRuntime().exec(), it causes a
  34. SIGSEGV and dumps core (the script does, not the Java program).
  35.  
  36.  
  37. We can invoke the script from the command line as follows, and it is
  38. successful:
  39.  
  40. ==================
  41. /usr/local/impress/bin/submitFileFTP 192.168.30.92 ftpuser password
  42. foo/IN /usr/local/foo/IN/bar.xml
  43. ==================
  44.  
  45. All of the above files exist, and the script executes fine. At the end
  46. of the launch, the following appears on the terminal window.
  47.  
  48. ==================
  49. Connected to 192.168.30.92.
  50. User ftpuser logged in.
  51. REST command not implemented.
  52. Remote system type is UNIX.
  53. Default transfer mode is BINARY
  54. CWD command successful.
  55. C-Kermit 8.0.200, 12 Dec 2001, inttranim [192.168.30.43]
  56.  
  57.    Current Directory: /usr/local/impress/bin
  58.         Network Host: 192.168.30.92 (UNIX)
  59.         Network Type: TCP/IP
  60.               Parity: none
  61.          RTT/Timeout: 00 / 00
  62.              FTP PUT:  => bar.xml
  63.            File Type: TEXT (no translation)
  64.            File Size: 49493
  65.         Percent Done: 100
  66. //////////////////////////////////////////////////
  67.                          
  68. ...10...20...30...40...50...60...70...80...90..100
  69.         Elapsed Time: 00:00:00
  70.   Transfer Rate, CPS: 419432
  71.         Window Slots: N/A
  72.          Packet Type: N/A
  73.            I/O Count: 6
  74.           I/O Length: 1659
  75.          Error Count: 0
  76.           Last Error:
  77.         Last Message: SUCCESS.  Files: 1, Bytes: 49493, 419432 CPS
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. Goodbye.
  85. ==================
  86.  
  87. We even have a log file that proves that the transfer was successful: 
  88.  
  89. ==================
  90. Args: 192.168.30.92 ftpuser 0resuptf1 foo/IN /usr/local/foo/IN/bar.xml
  91. CMD: ftp open 192.168.30.92 /user:ftpuser /password:password
  92. OK: ftp open 192.168.30.92 /user:ftpuser /password:password
  93. OK: ftp login successful
  94. CMD: ftp cd foo/IN/tmp
  95. OK: cd foo/IN/tmp
  96. CMD: ftp check bar.xml
  97. OK: ftp check bar.xml
  98. CMD: ftp put /usr/local/foo/IN/bar.xml
  99. ftp put TEXT: /usr/local/foo/IN/bar.xml
  100.  as bar.xml
  101.  character sets: no conversion
  102.  complete, size: 49493
  103. OK: ftp put /usr/local/foo/IN/bar.xml
  104. CMD: ftp check foo/IN/bar.xml
  105. OK: ftp check foo/IN/bar.xml
  106. CMD: ftp rename bar.xml../bar.xml
  107. OK: ftp rename bar.xml../bar.xml
  108. submitFileFTP was successful
  109. Transaction Log Closed
  110. ==================
  111.  
  112.  
  113. So far, so good. 
  114.  
  115. BUT: the same script, when invoked using java
  116. Runtime.getRuntime().exec(), bombs with SIGSEGV, and dumps core.
  117.  
  118. ==================
  119.  /opt/imp_engine/Solaris_JRE_1.1.8_12/bin/jre -verbose -ss8M -oss80M
  120. -ms32M -mx128M -cp . Executor /usr/local/impress/bin/submitFileFTP
  121. 192.168.30.92 ftpuser password foo/IN /usr/local/foo/IN/bar.xml
  122.  
  123. [lots of "loaded from" messages skipped]
  124.  
  125. out: Connected to 192.168.30.92.
  126. out: User ftpuser logged in.
  127. out: REST command not implemented.
  128. out: Remote system type is UNIX.
  129. out: Default transfer mode is BINARY
  130. out: CWD command successful.
  131. exit value: 11
  132. ==================
  133.  
  134. After this program has run, a core file exists in the current
  135. directory, whereas before, no such core file existed.
  136.  
  137. ==================
  138. Transaction Log: C-Kermit 8.0.200 Beta.03, 9 Sep 2001
  139.  Solaris 8
  140. Mon Feb  4 08:06:57 2002
  141.  
  142. Args: 192.168.30.92 ftpuser 0resuptf1 foo/IN /usr/local/foo/IN/bar.xml
  143. CMD: ftp open 192.168.30.92 /user:ftpuser /password:password
  144. OK: ftp open 192.168.30.92 /user:ftpuser /password:password
  145. OK: ftp login successful
  146. CMD: ftp cd foo/IN/tmp
  147. OK: cd foo/IN/tmp
  148. CMD: ftp check bar.xml
  149. OK: ftp check bar.xml
  150. CMD: ftp put /usr/local/foo/IN/bar.xml
  151. ftp put TEXT: /usr/local/foo/IN/bar.xml
  152.  as bar.xml
  153.  character sets: no conversion
  154.  complete, size: 49493
  155. OK: ftp put /usr/local/foo/IN/bar.xml
  156. CMD: ftp foo/IN/bar.xml
  157. ==================
  158.  
  159. No Transaction Log Closed in the above log file. The application
  160. terminates (dumps core) before it can write anything nice in there.
  161.  
  162. The Executor class is a vanilla java application that uses exec():
  163.  
  164. ==================
  165. import java.io.*;
  166. import java.util.*;
  167.  
  168. public class Executor {
  169.  
  170.   public static int execute(String app) throws IOException {
  171.     String[] arr = Executor.string2StringArray(app, " ");
  172.     return Executor.execute(arr);
  173.   }
  174.  
  175.   public static int execute(String[] app) throws IOException {
  176.     Runtime rt = null;
  177.     Process prcs = null;
  178.  
  179.     try {
  180.       rt = Runtime.getRuntime();
  181.       prcs = rt.exec(app);
  182.     } catch(IOException ioe) {
  183.       System.err.println("Exception in Executor: " + ioe);
  184.       ioe.printStackTrace();
  185.     }
  186.  
  187.     boolean exited = false;
  188.     int exitValue = -2;
  189.  
  190.     while (!exited) {
  191.       try  {
  192.         prcs.waitFor(); 
  193.         exited = true;
  194.         exitValue = prcs.exitValue();
  195.       } catch(InterruptedException ex) {
  196.         System.err.println("Exception in Executor: " + ex);
  197.         ex.printStackTrace();
  198.       } catch(IllegalThreadStateException _ex) {
  199.         System.err.println("Exception in Executor: " + _ex);
  200.         _ex.printStackTrace();
  201.       }
  202.     }
  203.  
  204.     /*
  205.     while(!exited) {
  206.       exited = true;
  207.       try  {
  208.         exitValue = prcs.exitValue();
  209.         System.out.println("Exit value : " + exitValue);
  210.       } catch(IllegalThreadStateException _ex) {
  211.         exited = false;
  212.       } catch(Exception _ex) {
  213.         return -3;
  214.       }
  215.     }
  216.     */
  217.  
  218.     // getInputStream(): Gets the input stream of the subprocess. This
  219. stream is usually buffered.
  220.     // the input stream connected to the normal output of the
  221. subprocess.
  222.     showStream(prcs.getInputStream(), "out");
  223.     showStream(prcs.getErrorStream(), "err");
  224.  
  225.     System.out.println("exit value: " + exitValue);
  226.     return exitValue;
  227.   }
  228.  
  229.  
  230.   public static void showStream (InputStream is, String desc) {
  231.     try {
  232.       BufferedReader br = new BufferedReader(new
  233. InputStreamReader(is));
  234.       String aline = "";
  235.       while ((aline = br.readLine()) != null) {
  236.         System.out.println(desc + ": " + aline);
  237.       }
  238.     } catch (IOException ioe) {
  239.       ioe.printStackTrace();
  240.     }
  241.   }
  242.  
  243.  
  244.   public static String[] string2StringArray(String string, String
  245. delimiter) {
  246.     StringTokenizer st = new StringTokenizer(string, delimiter);
  247.     String array[] = new String[st.countTokens()];
  248.     for(int cnt = 0; st.hasMoreTokens(); cnt++)
  249.       array[cnt] = st.nextToken();
  250.     return array;
  251.   }
  252.  
  253.   public static void main(String[] args) {
  254.     if (args.length == 0) {
  255.       System.out.println("I need argument(s)");
  256.     } else {
  257.       try { 
  258.         execute(args);
  259.       } catch (IOException ex) {
  260.         ex.printStackTrace();
  261.       }
  262.     }
  263.   }
  264. }
  265. ==================
  266. Playing with the jre memory settings (doubling each setting) does not
  267. help.
  268.  
  269. Finally, when one analyses the core file, one finds that the SIGSEGV
  270. occurs when the realfree() method is called, inside C-Kermit 8.0.200
  271. (same with the above beta version). Typically, this points to improper
  272. memory management by the programmer (see
  273. http://access1.sun.com/cgi-bin/rinfo2html?354005.faq).
  274.  
  275. ==================
  276. inttranim> adb kermit-8.0.200 core
  277. core file = core -- program ``submitFileFTP'' on platform
  278. SUNW,UltraAX-i2
  279. SIGSEGV: Segmentation Fault
  280. $m
  281. ? map
  282. b1 =            10000 e1 =           1a9b7a f1 =                0
  283. `kermit-8.0.200'
  284. b2 =           1b9b7c e2 =           26a05a f2 =           199b7c
  285. `kermit-8.0.200'
  286. b3 =         ff34c110 e3 =         ff367da0 f3 =             c110
  287. `/usr/lib/libcurses.so.1'
  288. b4 =         ff323868 e4 =         ff32997c f4 =             3868
  289. `/usr/lib/libsocket.so.1'
  290. b5 =         ff213ed4 e5 =         ff27d39c f5 =            13ed4
  291. `/usr/lib/libnsl.so.1'
  292. b6 =         ff2f1fd0 e6 =         ff300020 f6 =             1fd0
  293. `/usr/lib/libm.so.1'
  294. b7 =         ff1b8300 e7 =         ff1dfdc4 f7 =             8300
  295. `/usr/lib/libresolv.so.2'
  296. b8 =         ff09b7f8 e8 =         ff11bb84 f8 =            1b7f8
  297. `/usr/lib/libc.so.1'
  298. b9 =         ff390850 e9 =         ff3908b0 f9 =              850
  299. `/usr/lib/libdl.so.1'
  300. b10 =         ff2c0c34 e10 =         ff2c2b80 f10 =              c34
  301. `/usr/lib/libmp.so.2'
  302. b11 =         ff1a0534 e11 =         ff1a35e8 f11 =              534
  303. `/usr/platform/SUNW,UltraAX-i2/lib/libc_psr.so.1'
  304. b12 =         ff181b18 e12 =         ff184c44 f12 =             1b18
  305. `/usr/lib/nss_files.so.1'
  306. / map
  307. b1 =           1b8000 e1 =           26c000 f1 =             1c40
  308. `core'
  309. b2 =           26c000 e2 =           5c6000 f2 =            b5c40
  310. `core'
  311. b3 =         ff138000 e3 =         ff140000 f3 =           40fc40
  312. `core'
  313. b4 =         ff196000 e4 =         ff198000 f4 =           417c40
  314. `core'
  315. b5 =         ff1f4000 e5 =         ff1f8000 f5 =           419c40
  316. `core'
  317. b6 =         ff1f8000 e6 =         ff1fa000 f6 =           41dc40
  318. `core'
  319. b7 =         ff29a000 e7 =         ff2a2000 f7 =           41fc40
  320. `core'
  321. b8 =         ff2a2000 e8 =         ff2aa000 f8 =           427c40
  322. `core'
  323. b9 =         ff2b0000 e9 =         ff2b2000 f9 =           42fc40
  324. `core'
  325. b10 =         ff2d4000 e10 =         ff2d6000 f10 =           431c40
  326. `core'
  327. b11 =         ff314000 e11 =         ff316000 f11 =           433c40
  328. `core'
  329. b12 =         ff33a000 e12 =         ff33c000 f12 =           435c40
  330. `core'
  331. b13 =         ff37a000 e13 =         ff382000 f13 =           437c40
  332. `core'
  333. b14 =         ff382000 e14 =         ff384000 f14 =           43fc40
  334. `core'
  335. b15 =         ff3a0000 e15 =         ff3a2000 f15 =           441c40
  336. `core'
  337. b16 =         ff3e2000 e16 =         ff3e4000 f16 =           443c40
  338. `core'
  339. b17 =         ffbe0000 e17 =         ffbf0000 f17 =           445c40
  340. `core'
  341. $C
  342. realfree(725b7940,ff13e8b0,ff138018,0,72002009,5b5940) + 70
  343.         [savfp=0xffbedeb0,savpc=0xff0c23e4]
  344. cleanfree(0,ff138018,ff13e824,ff13e8a4,ff13e83c,0) + 58
  345.         [savfp=0xffbedf10,savpc=0xff0c1518]
  346. _malloc_unlocked(10,76c28,ff138018,10,2235c,0) + f0
  347.         [savfp=0xffbedf70,savpc=0xff0c140c]
  348. malloc(10,202ec0,0,1bda0c,28c8ac,ff00) + 20
  349.         [savfp=0xffbedfd0,savpc=0x3eb58]
  350. zchko(28c8ac,d,10,0,d,52455452) + 198
  351.         [savfp=0xffbee030,savpc=0x183dcc]
  352. ftpopen(28c8ac,fabc8,319af8,0,269dc4,0) + 3270
  353.         [savfp=0xffbee238,savpc=0x1877e8]
  354. ftp_dpl_mode(1bb000,1fa800,28c8ac,1fc654,269d50,0) + 358
  355.         [savfp=0xffbee2a8,savpc=0x17f5ac]
  356. doxftp(1cbc00,10,1fb2e8,ffffffff,ffffffff,295620) + 1044
  357.         [savfp=0xffbee590,savpc=0x115b14]
  358. docmd(75,75,1bb1f8,1c2068,20bf88,a) + 1270
  359.         [savfp=0xffbef558,savpc=0xc1118]
  360. parser(1bb000,1bb1f8,1cb400,1,2df8a0,1) + 19f0
  361.         [savfp=0xffbef5c8,savpc=0x29c58]
  362. docmdfile(1bb390,1,1bb19c,fabc8,faedc,0) + 74
  363.         [savfp=0xffbef628,savpc=0x137530]
  364. cc_execute(2febf0,29be4,29c9c,1d8104,207850,1bb1f8) + 44
  365.         [savfp=0xffbef690,savpc=0x2affc]
  366. main(1bb000,1ba800,8,2febf0,0,0) + 9e8
  367.         [savfp=0x0,savpc=0x28c50]
  368. $r
  369. g0    0                                 l0      0
  370. g1    ff115ba0      _return_zero        l1      0
  371. g2    0                                 l2      0
  372. g3    2f                                l3      0
  373. g4    279a44                            l4      0
  374. g5    0                                 l5      0
  375. g6    0                                 l6      0
  376. g7    0                                 l7      0
  377. o0    72002008                          i0      725b7940
  378. o1    ff13e810      List                i1      ff13e8b0    Root
  379. o2    0                                 i2      ff138018
  380. o3    5b5938                            i3      0
  381. o4    5b1ba8                            i4      72002009
  382. o5    0                                 i5      5b5940
  383. sp    ffbede50                          fp      ffbedeb0
  384. o7    ff0c1a74      realfree+0x4        i7      ff0c23e4   
  385. cleanfree+0x58
  386. y     0
  387. tstate: 82001a05  (ccr=0x0, asi=0x82, pstate=0x1a, cwp=0x5)
  388. pstate: ag:0 ie:1 priv:0 am:1 pef:1 mm:0 tle:0 cle:0 mg:0 ig:0
  389. pc    ff0c1ae0 realfree+0x70:   ld      [%i0 + 0x8], %o2
  390. npc   ff0c1ae4 realfree+0x74:   mov     %o3, %i3
  391.  
  392. ==================
  393.  
  394. It seems like Kermit is trying to perform a malloc, and has corrupted
  395. memory in the heap, at or near 725b7940. But then, Kermit does not act
  396. the same according to whether it is launched by "jre" or by "sh".
  397.  
  398. I'm stomped. Any of you have an idea?
  399.  
  400. TIA!
  401.  
  402. Ulrich Kroener
  403. Application Integrator
  404. GHX Europe
  405.